import React, { useState } from "react";
import { View, Image } from "@tarojs/components";
import Taro, { useDidShow } from "@tarojs/taro";

import api from "@api/api.js";

import hongbao from "@assets/workbench/hongbao.png";

import "./index.less";

export default () => {
  const [dtl, setDtl] = useState({});
  useDidShow(() => {
    getMe();
  });
  // 获取个人资料
  const getMe = async () => {
    const { data } = await api.getMe();
    setDtl(data);
  };
  // 查看体现记录
  const goList = () => {
    Taro.navigateTo({ url: `/pages/withdrawal/index` });
  };
  return (
    <View className="redPacket">
      <View className="img">
        <Image src={hongbao} />
      </View>
      <View className="title">红包余额</View>
      <View className="num">
        <View className="numIcon">￥</View>
        {dtl.consultPrice}
      </View>
      <View className="btn">提现</View>
      <View className="list" onClick={goList}>
        查看提现记录
      </View>
    </View>
  );
};
